﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d">
	<Style x:Key="TreeViewStyle" TargetType="{x:Type TreeView}">
		<Setter Property="Template" Value="{DynamicResource TreeViewControlTemplate}"/>
		<Setter Property="Background" Value="{x:Null}"/>
		<Setter Property="BorderBrush" Value="{x:Null}"/>
		<Setter Property="ItemContainerStyle" Value="{DynamicResource TreeViewItemStyle}"/>
	</Style>
	<ControlTemplate x:Key="TreeViewControlTemplate" TargetType="{x:Type TreeView}">
		<Grid>
			<Border x:Name="Border" Background="{DynamicResource BrushControlBackgroundLight}" BorderBrush="{DynamicResource ImpassiveColor4}" BorderThickness="{DynamicResource ThicknessSize_1}" CornerRadius="{DynamicResource CornerRadiusSmall}">
				<ScrollViewer Style="{DynamicResource SimpleScrollViewer}" Focusable="False" Background="{TemplateBinding Background}" Padding="4" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto" CanContentScroll="False">
					<ItemsPresenter/>
				</ScrollViewer>
			</Border>
		</Grid>
	</ControlTemplate>
	<!-- Resource dictionary entries should be defined here. -->
	<Style x:Key="TreeViewItemFocusVisual">
		<Setter Property="Control.Template">
			<Setter.Value>
				<ControlTemplate>
					<Rectangle/>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	<Style x:Key="ExpandCollapseToggleStyle" TargetType="{x:Type ToggleButton}">
		<Setter Property="Focusable" Value="False"/>
		<Setter Property="Width" Value="19"/>
		<Setter Property="Height" Value="13"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ToggleButton}">
					<Border Width="19" Height="13" Background="Transparent">
						<Border Width="9" Height="9" SnapsToDevicePixels="true" BorderBrush="#FF7898B5" BorderThickness="1" CornerRadius="1">
							<Border.Background>
								<LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
									<GradientStop Color="White" Offset=".2"/>
									<GradientStop Color="#FFC0B7A6" Offset="1"/>
								</LinearGradientBrush>
							</Border.Background>
							<Path Fill="Black" Margin="1,1,1,1" x:Name="ExpandPath" Data="M 0 2 L 0 3 L 2 3 L 2 5 L 3 5 L 3 3 L 5 3 L 5 2 L 3 2 L 3 0 L 2 0 L 2 2 Z"/>
						</Border>
					</Border>
					<ControlTemplate.Triggers>
						<Trigger Property="IsChecked" Value="True">
							<Setter Property="Data" TargetName="ExpandPath" Value="M 0 2 L 0 3 L 5 3 L 5 2 Z"/>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<!--Simple TreeViewItem - The TreeViewItem template has a header which shows the Item and a Body which is an ItemsHost control which expands to show child items-->
	<!--<Style x:Key="TreeViewItemStyle" d:IsControlPart="True" TargetType="{x:Type TreeViewItem}">-->
    <Style TargetType="{x:Type TreeViewItem}">
		<Setter Property="Background" Value="Transparent"/>
		<Setter Property="HorizontalContentAlignment" Value="{Binding Path=HorizontalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
		<Setter Property="VerticalContentAlignment" Value="{Binding Path=VerticalContentAlignment, RelativeSource={RelativeSource AncestorType={x:Type ItemsControl}}}"/>
		<Setter Property="Padding" Value="1,0,0,0"/>
		<Setter Property="Template" Value="{DynamicResource TreeViewItemControlTemplate}"/>
	</Style>
	<ControlTemplate x:Key="TreeViewItemControlTemplate" TargetType="{x:Type TreeViewItem}">
		<Grid>
			<Grid.ColumnDefinitions>
				<ColumnDefinition MinWidth="19" Width="Auto"/>
				<ColumnDefinition Width="Auto"/>
				<ColumnDefinition Width="*"/>
			</Grid.ColumnDefinitions>
			<Grid.RowDefinitions>
				<RowDefinition Height="Auto"/>
				<RowDefinition/>
			</Grid.RowDefinitions>
			<ToggleButton x:Name="Expander" Style="{DynamicResource SimpleTreeViewItemToggleButton}" IsChecked="{Binding Path=IsExpanded, RelativeSource={RelativeSource TemplatedParent}}" ClickMode="Press"/>
			<Border Grid.Column="1" x:Name="Selection_Border" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="{TemplateBinding Padding}">
				<ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" x:Name="PART_Header" ContentSource="Header"/>
			</Border>
			<ItemsPresenter Grid.Column="1" Grid.ColumnSpan="2" Grid.Row="1" x:Name="ItemsHost"/>
		</Grid>
		<ControlTemplate.Triggers>
			<Trigger Property="IsExpanded" Value="false">
				<Setter Property="Visibility" Value="Collapsed" TargetName="ItemsHost"/>
			</Trigger>
			<Trigger Property="HasItems" Value="false">
				<Setter Property="Visibility" Value="Hidden" TargetName="Expander"/>
			</Trigger>
			<Trigger Property="IsSelected" Value="true">
				<Setter Property="Background" TargetName="Selection_Border" Value="#4CFFFFFF"/>
			</Trigger>
			<MultiTrigger>
				<MultiTrigger.Conditions>
					<Condition Property="IsSelected" Value="true"/>
					<Condition Property="IsSelectionActive" Value="false"/>
				</MultiTrigger.Conditions>
				<Setter Property="Background" TargetName="Selection_Border" Value="#4CFFFFFF"/>
			</MultiTrigger>
			<Trigger Property="IsEnabled" Value="false">
				<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
			</Trigger>
		</ControlTemplate.Triggers>
	</ControlTemplate>
</ResourceDictionary>